//
//  NewCityDynamicHeader.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/11/24.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "NewCityDynamicHeader.h"

@interface NewCityDynamicHeader()
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UILabel *rightLabel;
@property (weak, nonatomic) IBOutlet UIView *dianView;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIImageView *arrowView;

@property (weak, nonatomic) IBOutlet UILabel *middleLabel;
@end

@implementation NewCityDynamicHeader


- (void)awakeFromNib{
    
    [super awakeFromNib];
    
    self.bgView.backgroundColor = [UIColor whiteColor];
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.leftLabel.font = MYFONT(17);
    
    self.middleLabel.font = MYFONT(13);
    
    self.middleLabel.textColor = [UIColor blackColor];
    
    self.rightLabel.font = MYFONT(15);
    
    self.dianView.layer.cornerRadius = 2;
    self.dianView.layer.masksToBounds = YES;
    self.dianView.backgroundColor = [UIColor blackColor];
    
    
}

- (void)setModel:(SectionHeaderModel *)model{
    
    
    _model = model;
    
    self.leftLabel.text = _model.title;
    
    if (_model.subTitle.length > 0) {
        self.middleLabel.text = _model.subTitle;
        self.middleLabel.hidden = NO;
        self.dianView.hidden = NO;
    } else {
        
        self.middleLabel.hidden = YES;
        self.dianView.hidden = YES;
    }
    
    
    if ([_model.title isEqualToString:@"邻居一起来"]) {
        self.rightLabel.textColor = [UIColor redColor];
        self.rightLabel.hidden = YES;
        self.arrowView.hidden = YES;
        self.dianView.backgroundColor = [UIColor redColor];
        self.middleLabel.textColor = [UIColor redColor];
        self.bgView.backgroundColor = [UIColor whiteColor];

    } else {
        self.rightLabel.textColor = colorWithA(156, 156, 156, 1.0);;

        self.rightLabel.hidden = NO;
        
        self.arrowView.hidden = NO;

        self.dianView.backgroundColor = [UIColor redColor];
        
        self.middleLabel.textColor = [UIColor redColor];
        
        self.bgView.backgroundColor = colorWithA(236, 236, 236, 1.0);
        
//        if ([_model.title isEqualToString:@"新城动态"] || [_model.title isEqualToString:@"二手优品"]) {
//            if ([_model.title isEqualToString:@"新城动态"]) {
//                self.bgView.backgroundColor = [UIColor greenColor];
//            } else {
//                self.bgView.backgroundColor = [UIColor orangeColor];
//            }
//        } else {
//            self.bgView.backgroundColor = randomColor;
//
//        }


    }
}


- (IBAction)btnDidClick:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(commityHeaderDidClickWith:)]) {
        [self.delegate commityHeaderDidClickWith:self.model.title];
    }
    
}


@end
